package com.zzyl.nursing.controller.member;

import com.zzyl.common.core.controller.BaseController;
import com.zzyl.common.core.domain.AjaxResult;
import com.zzyl.nursing.dto.AddElderFamilyDto;
import com.zzyl.nursing.dto.DeviceDataListDto;
import com.zzyl.nursing.dto.FamilyPageQuery;
import com.zzyl.nursing.dto.UserLoginRequestDto;
import com.zzyl.nursing.service.IDeviceDataService;
import com.zzyl.nursing.service.IFamilyMemberService;
import com.zzyl.nursing.vo.LoginVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 老人家属Controller
 * 
 * @author ruoyi
 * @date 2024-09-19
 */
@RestController
@RequestMapping("/member/user")
@Api(tags = "老人家属的接口")
public class FamilyMemberController extends BaseController
{
    @Autowired
    private IFamilyMemberService familyMemberService;

    @Autowired
    private IDeviceDataService deviceDataService;

    @PostMapping("/login")
    @ApiOperation("小程序登录")
    public AjaxResult login(@RequestBody UserLoginRequestDto dto){
        LoginVo loginVo = familyMemberService.login(dto);
        return success(loginVo);
    }

    @PostMapping("/add")
    @ApiOperation("绑定家人")
    public AjaxResult add(@RequestBody AddElderFamilyDto addElderFamilyDto) {
        familyMemberService.add(addElderFamilyDto);
        return success();
    }

    @GetMapping("/my")
    @ApiOperation("查询家人列表")
    public AjaxResult queryMyFamilyMember() {
        return familyMemberService.queryMyFamilyMember();
    }

    @GetMapping("/queryServiceProperties/{iotId}")
    @ApiOperation("查询健康数据")
    public AjaxResult queryServiceProperties(@PathVariable("iotId") String iotId) {
        return deviceDataService.queryServiceProperties(iotId);
    }

    @GetMapping("/queryDeviceDataListByDay")
    @ApiOperation("按天统计查询指标数据")
    public AjaxResult queryDeviceDataListByDay(DeviceDataListDto deviceDataListByDayDto) {
        return deviceDataService.queryDeviceDataListByDay(deviceDataListByDayDto);
    }

    @GetMapping("/queryDeviceDataListByWeek")
    @ApiOperation("按周统计查询指标数据")
    public AjaxResult queryDeviceDataListByWeek(DeviceDataListDto deviceDataListByDayDto) {
        return deviceDataService.queryDeviceDataListByWeek(deviceDataListByDayDto);
    }

    @GetMapping("/list-by-page")
    @ApiOperation("查看家人列表")
    public AjaxResult listByPage(FamilyPageQuery familyPageQuery) {
        startPage();
        return familyMemberService.pageFamily();
    }

}
